package com.dongdong.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class Result<T> {
    private String code;
    private String msg;

    private T data;

    public Result(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static Result OK(){
        return new Result(ResultEnum.SUCCESS.getCODE(), ResultEnum.SUCCESS.getMSG());
    }

    public static Result FAIL(){
        return new Result(ResultEnum.ERROR.getCODE(), ResultEnum.ERROR.getMSG());
    }


    public static Result DATA(ResultEnum resultEnum){
        return new Result(resultEnum.getCODE(),resultEnum.getMSG());
    }

}
